package ex3.controller.demo2;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @AUTHOR 尹书岿
 * @DATE 2024/12/11 16:18
 * @DESCRIBE
 */
public class zhengze {
    public static void main(String[] args) {
        String info = "he43o   daSfd   ";
//        System.out.println(info.matches(""));
        Pattern pattern = Pattern.compile("^(\\w+)\\s+([0-9a-zA-Z]+)\\s+$");
        Matcher matcher = pattern.matcher(info);
        if (matcher.matches()){
//            System.out.println(matcher.group());  //匹配整个字符串
//            System.out.println(matcher.group(0));  //匹配整个字符串
//            System.out.println(matcher.group(1));
//            System.out.println(matcher.group(2));
//            System.out.println(matcher.groupCount());
            for (int i = 0;i <= matcher.groupCount(); i++){
                System.out.println(matcher.group(i));
            }
        }
    }
}
